import requests from './requests';
import mockRequests from './mockAjax';
//   获取三级联动列表api /api/product/getBaseCategoryList
//发请求:axios发请求返回的结果Promise对象
export const getBaseCategoryList = () =>
    requests.get(`/product/getBaseCategoryList`)
//获取banner（home轮播图数据）
export const reqGetListRecommend = () => mockRequests.get(`/banner`)
//获取floor（底部数据）
export const reqGetFloorList = () => mockRequests.get(`/floor`)
//获取search模块数据 post请求  params参数为对象，至少要是一个空对象，否则请求失败
export const reqPostSearch = (params) => requests(
    {
        url: '/list',
        method: "POST",
        data: params
    }
)
//detail组件 请求方式：/api/item/{ skuId } get
export const reqGetDetail = (skuId) => requests({
    url: `/item/${skuId}`,
    method: 'GET',
})
//添加到购物车的请求  /api/cart/addToCart/{ skuId }/{ skuNum } POST
export const reqPostShopCart = (skuId, skuNum) => requests({
    url: `/cart/addToCart/${skuId}/${skuNum}`,
    method: 'POST'
})
//获取用户的购物车商品信息  /api/cart/cartList
export const reqShopCart = () => requests({
    url: `/cart/cartList`,
    method: 'get'
})
//删除购物车里商品 /api/cart/deleteCart/{skuId}
export const reqDeleteGoods = (skuId) => requests({
    url: `/cart/deleteCart/${skuId}`,
    method: 'DELETE'
})
//切换商品的选中状态 /api/cart/checkCart/{skuId}/{isChecked}
export const reqCheckCart = ({ skuId, isChecked }) => requests({
    url: `/cart/checkCart/${skuId}/${isChecked}`
})
//获取手机验证码 /api/user/passport/sendCode/phone GET
export const reqIphoneCode = (phone) => requests({
    url: `/user/passport/sendCode/${phone}`,
    method: "get"
})
//用户注册 /api/user/passport/register POST
export const reqRegisterUser = (data) => requests({
    url: `/user/passport/register`,
    method: 'POST',
    data
})
//用户登录 /user/passport/register POST
export const reqUserLogin = (data) => requests({
    url: `/user/passport/login`,
    method: 'POST',
    data
})
//自动登录 /api/user/passport/auth/getUserInfo
//token已请求头的方式带给服务器
export const reqUserInfo = () => requests({
    url: `/user/passport/auth/getUserInfo`,
    method: 'GET'
})
//退出登录 /api/user/passport/logout
export const reqLogout = () => requests({
    url: `user/passport/logout`,
    method: 'get'
})
//获取用户地址信息
export const reqAddressInfo = () => requests({
    url: `/user/userAddress/auth/findUserAddressList`,
    method: 'get'
});
//获取订单交易页信息 /api/order/auth/trade
export const reqTradeInfo = () => requests({
    url: `/order/auth/trade`,
    method: 'get'
})
//提交订单 /api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder = (tradeNo, data) => requests({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: 'post',
    data
})
//获取订单支付信息
export const reqOrderPayInfo = (orderId) => requests({
    url: `/payment/weixin/createNative/${orderId}`,
    method: 'get'
})
//查询支付订单状态 /api/payment/weixin/queryPayStatus/{orderId}
export const reqOrderPayStatus = (orderId) => requests({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: "get"
})
//获取我的订单列表 /api/order/auth/{page}/{limit}
export const reqOrderList = (page, limit) => requests({
    url: `/order/auth/${page}/${limit}`,
    method: 'get'
})